package com.kaiwukj.android.ufamily.mvp.ui.page.service.property.notice;

import android.os.Bundle;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.kaiwukj.android.mcas.di.component.AppComponent;
import com.kaiwukj.android.ufamily.R;
import com.kaiwukj.android.ufamily.app.base.BaseSwipeBackFragment;
import com.kaiwukj.android.ufamily.di.component.DaggerServiceComponent;
import com.kaiwukj.android.ufamily.di.module.ServiceModule;
import com.kaiwukj.android.ufamily.mvp.http.entity.result.CommunityNoticeResult;
import com.kaiwukj.android.ufamily.mvp.ui.page.service.ServiceContract;
import com.qmuiteam.qmui.widget.QMUITopBar;

import java.util.List;

import butterknife.BindView;
import me.yokeyword.fragmentation.SupportActivity;


/**
 * Copyright © KaiWu Technology Company
 * 公告列表
 *
 * @author Haife
 * @job Android Development
 */
public class CommunityNoticeDetailFragment extends BaseSwipeBackFragment<CommunityNoticePresenter> implements ServiceContract.CommunityNoticeView {
    @BindView(R.id.qtb_community_notice_detail)
    QMUITopBar mQMUITopBar;

    @BindView(R.id.tv_community_notice_detail_title)
    TextView mTitle;

    @BindView(R.id.tv_community_notice_detail_time)
    TextView mCreatTime;

    @BindView(R.id.tv_community_notice_detail_note)
    TextView mNoticeTv;

    @BindView(R.id.tv_source)
    TextView tvSource;


    private CommunityNoticeResult item;

    public static CommunityNoticeDetailFragment newInstance(CommunityNoticeResult item) {
        CommunityNoticeDetailFragment fragment = new CommunityNoticeDetailFragment();
        fragment.item = item;
        return fragment;
    }

    @Override
    public void setupFragmentComponent(@NonNull AppComponent appComponent) {
        DaggerServiceComponent.builder()
                .appComponent(appComponent)
                .serviceModule(new ServiceModule(this))
                .build().inject(this);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_community_notice_detail;
    }

    @Override
    protected void initView() {
        mQMUITopBar.setTitle("公告详情");
        mQMUITopBar.addLeftBackImageButton().setOnClickListener(view -> {
            ((SupportActivity) getActivity()).onBackPressedSupport();
            //onBackPressedSupport();
        });
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {

        mTitle.setText(item.getTitle());
        mCreatTime.setText(item.getCreateTime());
        mNoticeTv.setText(item.getNote());
        tvSource.setText(item.getEstateName());
    }

    @Override
    public void onFetchResult(List<CommunityNoticeResult> results) {

    }

    @Override
    public void onGetResult(CommunityNoticeResult result) {

    }
}
